home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / NextAnswers / 1447_what_are_shared_libraries.rtf < prev    next >
Text File  |  1993-11-08  |  2KB  |  38 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f3\fswiss Helvetica;\f1\fmodern Ohlfs;}
  2. \paperw10840
  3. \paperh8320
  4. \margl120
  5. \margr120
  6. {\colortbl;\red0\green0\blue0;\red84\green84\blue84;\red83\green83\blue83;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs28\fc1\cf1 Q:  What's a shlib, and how does it affect me?\
  8. \
  9. A:  A shlib is a shared library.  It is a library that contains object code that several executable files may use simultaneously.   When a program is linked or compiled with a shared library, the library code that defines the external references are not copied into the object file.  Instead it binds the address to a branch table which points to the actual code.\
  10. \
  11. Shared libraries help save disk storage because the a.out files don't contain copies of the archive.  It also saves memory at runtime because the a.out files point to one copy of the code.  It helps to keep all applications up to date, because when a shared library is replaced, all applications use the new version without needing to be recompiled.  Unfortunately,  it is harder to maintain a shared library because there are more things that need to remain constant in order for new versions to be compatible.\
  12. \
  13. There are two parts in a shared library, the host library and the runtime library.  The host library gets linked in at compile time.  It's something like 
  14. \b /usr/lib/libNeXT_s.a
  15. \b0 .  (Note that there should also be a regular archive library that has all the profiling information in it—
  16. \b /usr/lib/libNeXT_p.a
  17. \b0 .)  The runtime or target library contains the branch table and the actual code.  It must be installed on the machine in order for the application to execute.  It's something like 
  18. \b /usr/shlib/libNeXT_s.C.shlib
  19. \b0 .  In this particular case,  C is the version letter.\
  20. \
  21. When compiled with 
  22. \b -lNeXT_s
  23. \b0 , an a.out contains the name of the file that it needs to use at runtime.  The 
  24. \b otool
  25. \b0  program, with the 
  26. \b -L
  27. \b0  option, shows which runtime libraries it expects.  (See the 
  28. \b otool
  29. \b0  man page.)\
  30. \
  31. The first application that touches the shared library pulls it into memory.  All others after that point to that copy in memory.\
  32. \
  33. QA402\
  34. \
  35. Valid for 1.0, 2.0, 3.0\
  36. \
  37.  
  38.